package com.tiyende.credit.loop.ui.adapter

import android.graphics.Color
import androidx.recyclerview.widget.RecyclerView
import com.lib.common.adapter.CommonRecyclerViewAdapter
import com.lib.common.adapter.CommonViewHolderHelper
import com.tiyende.credit.loop.R
import com.tiyende.credit.loop.weight.font.RobotoMediumTextView
import org.json.JSONObject

/**
 * TiyendeCredit
 * @Author wwdeng
 * @CreateTime: 2024/11/19 13:54
 * @Annotation：认证流程步骤适配器
 */
class TiyendeAuthenticationStepChooseChildItemAdapter(recyclerView: RecyclerView?) :
    CommonRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.tiyende_authentication_step_common_choose_item_choose_child) {
    override fun setItemChildListener(helper: CommonViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.txtAuthenticationStepCommonChooseChild)//选择
    }

    override fun fillData(helper: CommonViewHolderHelper, position: Int, model: JSONObject) {
        val txtAuthenticationStepCommonChooseChild = helper.getView<RobotoMediumTextView>(R.id.txtAuthenticationStepCommonChooseChild)
        txtAuthenticationStepCommonChooseChild.text = model.optString("title")
        if (model.optBoolean("isSelected", false)) {
            txtAuthenticationStepCommonChooseChild.shapeDrawableBuilder
                .setStrokeColor(Color.parseColor("#FF3ED9AB"))
                .setStrokeSize(mContext.resources.getDimension(com.lib.common.R.dimen.dp_2).toInt())
                .intoBackground()
        } else {
            txtAuthenticationStepCommonChooseChild.shapeDrawableBuilder
                .setStrokeColor(Color.parseColor("#FF334155"))
                .setStrokeSize(mContext.resources.getDimension(com.lib.common.R.dimen.dp_1).toInt())
                .intoBackground()
        }
    }
}